package com.skyline.attraction.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.attraction.model.AttractionFeature;
import com.skyline.base.type.Activity;

public class AttractionFeatureMapper implements RowMapper<AttractionFeature> {

	private final static String COLUMN_ID = "id";
	private final static String COLUMN_PORTRAIT = "portrait";
	private final static String COLUMN_ATTRACTION_ID = "attractionId";
	private final static String COLUMN_ATTRACTION_NAME = "attractionName";
	private final static String COLUMN_ATTRACTION_PORTRAIT = "attractionPortrait";
	private final static String COLUMN_OWNER_ID = "ownerId";
	private final static String COLUMN_OWNER_NICKNAME = "ownerNickname";
	private final static String COLUMN_OWNER_PORTRAIT = "ownerPortrait";
	private final static String COLUMN_CREATOR_ID = "creatorId";
	private final static String COLUMN_CREATOR_NICKNAME = "creatorNickname";
	private final static String COLUMN_CREATOR_PORTRAIT = "creatorPortrait";
	private final static String COLUMN_TITLE = "title";
	private final static String COLUMN_DETAIL = "detail";
	private final static String COLUMN_CONSUME = "consume";
	private final static String COLUMN_ALBUM_ID = "albumId";
	private final static String COLUMN_STAR = "star";
	private final static String COLUMN_VOTES = "votes";
	private final static String COLUMN_CREATETIME = "createTime";
	private final static String COLUMN_UPDATETIME = "updateTime";
	private final static String COLUMN_ACTIVITY = "activity";

	private final static AttractionFeatureMapper MAPPER = new AttractionFeatureMapper();

	public static AttractionFeatureMapper getMapper() {
		return MAPPER;
	}

	public AttractionFeature mapRow(ResultSet rs, int rowNum) throws SQLException {
		AttractionFeature feature = new AttractionFeature();
		feature.setId(Long.valueOf(rs.getString(COLUMN_ID)));
		feature.setPortrait(rs.getString(COLUMN_PORTRAIT));
		feature.setAttractionId(rs.getLong(COLUMN_ATTRACTION_ID));
		feature.setAttractionName(rs.getString(COLUMN_ATTRACTION_NAME));
		feature.setAttractionPortrait(rs.getString(COLUMN_ATTRACTION_PORTRAIT));
		feature.setOwnerId(Long.valueOf(rs.getString(COLUMN_OWNER_ID)));
		feature.setOwnerNickname(rs.getString(COLUMN_OWNER_NICKNAME));
		feature.setOwnerPortrait(rs.getString(COLUMN_OWNER_PORTRAIT));
		feature.setCreatorId(Long.valueOf(rs.getString(COLUMN_CREATOR_ID)));
		feature.setCreatorNickname(rs.getString(COLUMN_CREATOR_NICKNAME));
		feature.setCreatorPortrait(rs.getString(COLUMN_CREATOR_PORTRAIT));
		feature.setTitle(rs.getString(COLUMN_TITLE));
		feature.setDetail(rs.getString(COLUMN_DETAIL));
		feature.setConsume(rs.getInt(COLUMN_CONSUME));
		feature.setAlbumId(rs.getLong(COLUMN_ALBUM_ID));
		feature.setStar(rs.getFloat(COLUMN_STAR));
		feature.setVotes(rs.getInt(COLUMN_VOTES));
		feature.setCreateTime(rs.getDate(COLUMN_CREATETIME));
		feature.setUpdateTime(rs.getDate(COLUMN_UPDATETIME));
		feature.setActivity(Activity.valueOf((rs.getString(COLUMN_ACTIVITY))));
		return feature;
	}
}
